import java.util.concurrent.TimeUnit

import actors.Manager
import akka.actor.{Actor, ActorSystem, Props}
import akka.pattern.ask

import scala.concurrent.{Await, Future, duration}
import akka.util.Timeout
import halo.messages.{Run, StartTask}

import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.Success
/**
  * Created by jedi on 17-5-20.
  */
object Main {
  def main(args: Array[String]): Unit = {
    val system = ActorSystem("Spider")
    val myActor = system.actorOf(Props[Manager])
    myActor ! Run()
    myActor ! StartTask("hellow")
  }
}
//
//class A extends Actor {
//  val b = context.actorOf(Props[B], name = "myChild")
//  implicit val timeout: Timeout =  20  second
//
//  override def receive = {
//    case "test" => {
//      var c:Future[Any] = b .ask("is_busy")
////      var r = c. Await.result(c, Duration(2,TimeUnit.SECONDS))
////      c.map(x=>println(x))
//      println("hahha",c)
//      c.flatMap(x => Future{ x+"a"}).foreach(a=>println(a,"future 执行"))
//      c onComplete{
//        case Success(posts)=>println("收到yes")
//
//      }
//
//    }
//  }
//}
//
//class B extends Actor {
//  override def receive = {
//    case "is_busy" => {
//      println("yes")
//      sender()!"yes"
//    }
//  }
//}